package com.beta.resource.utils.shell;

import org.apache.commons.exec.ProcessDestroyer;

public class BaseShellProcessDestroyer implements ProcessDestroyer{
    private Process mProcess;
    
    @Override
    public boolean add(Process process) {
        mProcess = process;
        return true;
    }

    @Override
    public boolean remove(Process process) {
        if(mProcess != null && mProcess.isAlive()){
            mProcess.destroy();
        }
        mProcess = null;
        return true;
    }

    public void stop(){
        if(mProcess != null && mProcess.isAlive()){
            mProcess.destroy();
        }
    }

    @Override
    public int size() {
        return 1;
    }
    
}
